package com.iyitong.account.dao.impl;

import java.sql.SQLException;
import java.util.List;

import com.iyitong.account.dao.AccountDao;
import com.iyitong.account.entity.Account;
import com.iyitong.common.dao.impl.DaoTemplate;
import com.iyitong.common.entity.BaseEntity;

public class AccountDaoImpl extends DaoTemplate implements AccountDao {

	private static final String INSERT_ACCOUNT = "account.insertAccount";
	private static final String VALIDATE_ACCOUNT = "account.validateAccount";
	private static final String CHECK_ACCOUNT = "account.checkAccount";

	@Override
	public int createAccount(Account account) throws SQLException {
		// TODO Auto-generated method stub
		return insert(INSERT_ACCOUNT, account);
	}

	@Override
	public Account validateAccount(Account account) throws SQLException {
		// TODO Auto-generated method stub
		List<BaseEntity> list = queryForList(VALIDATE_ACCOUNT, account);
		return list.isEmpty() ? null : (Account)list.get(0);
	}

	@Override
	public Account checkAccount(Account account) throws SQLException {
		// TODO Auto-generated method stub
		List<BaseEntity> list = queryForList(CHECK_ACCOUNT, account);
		return list.isEmpty() ? null : (Account)list.get(0);
	}
}